package com.peng.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.text.StringSubstitutor;
import org.junit.jupiter.api.Test;

/**
 * GenerateBeehiveDecisionSceneFieldSqlTest1
 *
 * @author lupeng10
 * @create 2024-03-21 17:35
 */
public class GenerateBeehiveDecisionSceneFieldSqlTest1 {


    @Test
    public void t3() {
        String sqlTem = """
                INSERT INTO t_decision_scene (id, unikey, terminal, name, source, state, created_at, created_by, updated_at, updated_by) VALUES (${sceneId}, '${unikey}', null, '${sceneName}', 0, 1, '2024-01-11 15:08:49', 'lupeng10', '2024-01-11 15:08:49', 'lupeng10');
                
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id1}, 1, 'smsEventId', '短信eventId', 1, ${sceneId}, null, null, '2024-02-22 11:42:15', 'lupeng10', '2024-02-22 11:42:15', 'lupeng10', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id2}, 1, 'smsDynamicParams', '短信动态参数(按顺序添加)', 6, ${sceneId}, null, null, '2024-02-22 11:42:16', 'lupeng10', '2024-02-22 11:42:16', 'lupeng10', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id3}, 1, 'dynamicParamType', '参数类型', 7, ${sceneId}, '[{"disabled":false,"label":"自定义","value":"0"},{"disabled":false,"label":"用户最近一次发帖一级城市","value":"1"},{"disabled":false,"label":"用户最近一次发帖四级类目","value":"2"},{"disabled":false,"label":"生成的H5页面链接","value":"3"}]', null, '2024-02-22 11:42:16', 'lupeng10', '2024-02-22 11:42:16', 'lupeng10', ${id2});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id4}, 1, 'value', '动态参数值', 1, ${sceneId}, null, null, '2024-02-22 11:42:16', 'lupeng10', '2024-02-22 11:42:16', 'lupeng10', ${id2});
                
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id5}, 1, 'title', '小助手消息title', 1, ${sceneId}, null, null, '2024-02-22 11:42:16', 'lupeng10', '2024-02-22 11:42:16', 'lupeng10', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id6}, 1, 'tipTitle', '小助手消息tipTitle', 1, ${sceneId}, null, null, '2024-02-22 11:42:16', 'lupeng10', '2024-02-22 11:42:16', 'lupeng10', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id7}, 1, 'showLines', '小助手消息showLines', 1, ${sceneId}, null, null, '2024-02-22 11:42:16', 'lupeng10', '2024-02-22 11:42:16', 'lupeng10', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id8}, 1, 'linkType', '跳转链接类型', 7, ${sceneId}, '[{"disabled":false,"label":"自定义","value":"0"},{"disabled":false,"label":"优惠券H5","value":"1"}]', null, '2024-02-22 11:42:17', 'lupeng10', '2024-02-22 11:42:17', 'lupeng10', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id9}, 1, 'routeAction', '五八跳转链接', 1, ${sceneId}, null, null, '2024-02-22 11:42:17', 'lupeng10', '2024-02-22 11:42:17', 'lupeng10', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id10}, 1, 'ganjiRouteAction', '赶集跳转链接', 1, ${sceneId}, null, null, '2024-02-22 11:42:17', 'lupeng10', '2024-02-22 11:42:17', 'lupeng10', 0);
                
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id11}, 1, 'couponArr', '优惠券', 6, ${sceneId}, null, null, '2024-02-22 11:42:17', 'lupeng10', '2024-02-22 11:42:17', 'lupeng10', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id12}, 1, 'couponId', '优惠券模版ID', 1, ${sceneId}, null, null, '2024-02-22 11:42:17', 'lupeng10', '2024-02-22 11:42:17', 'lupeng10', ${id11});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id13}, 1, 'couponTermType', '优惠券有效期类型', 7, ${sceneId}, '[{"disabled":false,"label":"有效天数","value":"1"},{"disabled":false,"label":"有效时间范围","value":"2"}]', null, '2024-02-22 11:42:17', 'lupeng10', '2024-02-22 11:42:17', 'lupeng10', ${id11});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id14}, 1, 'couponEffectDays', '优惠券有效时间(天)', 1, ${sceneId}, null, null, '2024-01-11 15:08:49', 'lupeng10', '2024-02-22 11:42:18', 'lupeng10', ${id11});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id15}, 1, 'couponEffectDays1', '优惠券有效期结束时间(天)', 1, ${sceneId}, null, null, '2024-02-22 11:42:18', 'lupeng10', '2024-02-22 11:42:18', 'lupeng10', ${id11});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id16}, 1, 'effectTimeRange', '有效期固定时间', 10, ${sceneId}, null, null, '2024-02-22 11:42:18', 'lupeng10', '2024-02-22 11:42:18', 'lupeng10', ${id11});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id17}, 1, 'couponRateLimiterCount', '优惠券频控限制count', 1, ${sceneId}, null, null, '2024-02-22 11:42:18', 'lupeng10', '2024-02-22 11:42:18', 'lupeng10', ${id11});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id18}, 1, 'couponRateLimiterCycle', '优惠券频控限制day', 1, ${sceneId}, null, null, '2024-02-22 11:42:18', 'lupeng10', '2024-02-22 11:42:18', 'lupeng10', ${id11});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id19}, 1, 'productType', '商业产品类型', 8, ${sceneId}, null, '1', '2024-02-22 11:42:19', 'lupeng10', '2024-02-22 11:42:19', 'lupeng10', ${id11});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id20}, 1, 'couponNeedClick', '是否点击领取', 7, ${sceneId}, '[{"disabled":false,"label":"立即发送","value":"0"},{"disabled":false,"label":"点击领取","value":"1"}]', null, '2024-02-22 11:42:19', 'lupeng10', '2024-02-22 11:42:19', 'lupeng10', ${id11});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id21}, 1, 'couponShowTitle', '标题', 1, ${sceneId}, null, null, '2024-02-22 11:42:19', 'lupeng10', '2024-02-22 11:42:19', 'lupeng10', ${id11});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id22}, 1, 'couponShowDiscountNum', '折扣数量', 1, ${sceneId}, null, null, '2024-02-22 11:42:19', 'lupeng10', '2024-02-22 11:42:19', 'lupeng10', ${id11});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id23}, 1, 'couponShowDiscountUnit', '折扣单位', 1, ${sceneId}, null, null, '2024-02-22 11:42:19', 'lupeng10', '2024-02-22 11:42:19', 'lupeng10', ${id11});
                
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id24}, 1, 'couponH5', '优惠券H5', 5, ${sceneId}, null, null, '2024-02-22 11:42:19', 'lupeng10', '2024-02-22 11:42:19', 'lupeng10', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id25}, 1, 'generateH5Flag', '是否生成H5落地页', 7, ${sceneId}, '[{"disabled":false,"label":"不生成","value":"0"},{"disabled":false,"label":"生成","value":"1"}]', null, '2024-02-22 11:42:20', 'lupeng10', '2024-02-22 11:42:20', 'lupeng10', ${id24});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id26}, 1, 'buriedParam', '埋点参数', 1, ${sceneId}, null, null, '2024-02-22 11:42:20', 'lupeng10', '2024-02-22 11:42:20', 'lupeng10', ${id24});
                
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id27}, 1, 'favorablePopup', '优惠券弹窗', 5, ${sceneId}, null, null, '2024-03-01 10:29:29', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id28}, 1, 'favorablePopupFlag', '是否展示', 7, ${sceneId}, '[{"disabled":false,"label":"不展示","value":"0"},{"disabled":false,"label":"展示","value":"1"}]', null, '2024-03-01 10:29:29', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', ${id27});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id29}, 1, 'favorablePopupType', '样式', 7, ${sceneId}, '[{"disabled":false,"label":"优惠券","value":"1"},{"disabled":false,"label":"图文","value":"2"}]', null, '2024-03-01 10:29:29', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', ${id27});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id30}, 1, 'favorablePopupBg', '背景图', 2, ${sceneId}, null, null, '2024-03-01 10:29:29', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', ${id27});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id31}, 1, 'favorablePopupTitleImg', '标题图片', 2, ${sceneId}, null, null, '2024-03-01 10:29:29', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', ${id27});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id32}, 1, 'favorablePopupCardBg', '卡片背景图', 2, ${sceneId}, null, null, '2024-03-01 10:29:29', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', ${id27});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id33}, 1, 'favorablePopupContent', '第一行文案', 1, ${sceneId}, null, null, '2024-03-01 10:29:29', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', ${id27});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id34}, 1, 'favorablePopupBtnText', '按钮文案', 1, ${sceneId}, null, null, '2024-03-01 10:29:29', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', ${id27});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id35}, 1, 'favorablePopupUrlType', '跳转链接类型', 7, ${sceneId}, '[{"disabled":false,"label":"自定义","value":"0"},{"disabled":false,"label":"优惠券H5","value":"1"}]', null, '2024-03-01 10:29:29', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', ${id27});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id36}, 1, 'favorablePopup58Url', '58跳转链接', 1, ${sceneId}, null, null, '2024-03-01 11:52:08', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', ${id27});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id37}, 1, 'favorablePopupGjUrl', '赶集跳转链接', 1, ${sceneId}, null, null, '2024-03-01 11:52:08', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', ${id27});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id38}, 1, 'favorablePopupZcmUrl', 'ZCM跳转链接', 1, ${sceneId}, null, null, '2024-03-01 11:52:08', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', ${id27});
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES (${id39}, 1, 'favorablePopupBuriedParam', '埋点参数', 1, ${sceneId}, null, null, '2024-03-01 15:19:20', 'lupeng10', '2024-03-01 15:19:20', 'lupeng10', ${id27});
                
                insert into t_decision_scene_field (`id`,`scope`,`field_key`,`field_name`,`field_type`,`scene_id`,`options`,`callback_url`,`created_at`,`created_by`,`updated_at`,`updated_by`,`parentId`) values('${id40}','1','frequencyControl','频控','5','${sceneId}',NULL,NULL,'2024-03-18 19:26:13','lupeng10','2024-03-18 19:26:13','lupeng10','0');
                insert into t_decision_scene_field (`id`,`scope`,`field_key`,`field_name`,`field_type`,`scene_id`,`options`,`callback_url`,`created_at`,`created_by`,`updated_at`,`updated_by`,`parentId`) values('${id41}','1','frequencyControlCycle','N天1次','8','${sceneId}',NULL,'9','2024-03-18 19:26:13','lupeng10','2024-03-18 19:26:13','lupeng10','${id40}');
                """;

        long sceneId = Long.parseLong("1787740403131269123");
        long id = Long.parseLong("1787740403148058629");
        List<SceneKeyName> sceneKeyNames = new ArrayList<>();
        sceneKeyNames.add(new SceneKeyName(sceneId, "b_user_unread_msg_push", "B未读效果推送提醒"));

        for (SceneKeyName sceneKeyName : sceneKeyNames) {
            Map<String, Object> params = new HashMap<>();
            params.put("sceneId", sceneKeyName.getSceneId());
            params.put("unikey", sceneKeyName.getUniqueKey());
            params.put("sceneName", sceneKeyName.getSceneName());
            params.put("id1", id++);
            params.put("id2", id++);
            params.put("id3", id++);
            params.put("id4", id++);
            params.put("id5", id++);
            params.put("id6", id++);
            params.put("id7", id++);
            params.put("id8", id++);
            params.put("id9", id++);
            params.put("id10", id++);
            params.put("id11", id++);
            params.put("id12", id++);
            params.put("id13", id++);
            params.put("id14", id++);
            params.put("id15", id++);
            params.put("id16", id++);
            params.put("id17", id++);
            params.put("id18", id++);
            params.put("id19", id++);
            params.put("id20", id++);
            params.put("id21", id++);
            params.put("id22", id++);
            params.put("id23", id++);
            params.put("id24", id++);
            params.put("id25", id++);
            params.put("id26", id++);
            params.put("id27", id++);
            params.put("id28", id++);
            params.put("id29", id++);
            params.put("id30", id++);
            params.put("id31", id++);
            params.put("id32", id++);
            params.put("id33", id++);
            params.put("id34", id++);
            params.put("id35", id++);
            params.put("id36", id++);
            params.put("id37", id++);
            params.put("id38", id++);
            params.put("id39", id++);
            params.put("id40", id++);
            params.put("id41", id++);
            String sql = new StringSubstitutor(params).replace(sqlTem);
            System.out.println(sql);
        }
    }

    @Test
    public void genFranceControlTest() {
        String sqlTem = """
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId) VALUES
                (${id1}, 1, 'frequencyControl', '频控', 5, ${sceneId}, null, null, '2024-03-18 19:26:13', 'lupeng10', '2024-03-18 19:26:13', 'lupeng10', 0),
                (${id2}, 1, 'frequencyControlCycle', 'N天1次', 8, ${sceneId}, null, '9', '2024-03-18 19:26:13', 'lupeng10', '2024-03-18 19:26:13', 'lupeng10', ${id1});
                """;
        List<String> sceneIdList = new ArrayList<>();
        sceneIdList.add("1745341975739023360");
        sceneIdList.add("1745341976183619596");
        sceneIdList.add("1745341976183619607");
        sceneIdList.add("1745341976183619651");
        sceneIdList.add("1745341976183619662");
        sceneIdList.add("1745341976183619673");
        sceneIdList.add("1745341976183619684");
        sceneIdList.add("1745341976183619728");
        sceneIdList.add("1750721922401886209");
        sceneIdList.add("1750721922401886210");
        sceneIdList.add("1760970543273664515");
        sceneIdList.add("1760970838561050625");
        sceneIdList.add("1770739816883875843");
        sceneIdList.add("1770739816883875844");
        sceneIdList.add("1770739816883875845");
        sceneIdList.add("1770739816883875846");
        sceneIdList.add("1770739816883875847");
        sceneIdList.add("1770739816883875848");

        long id = 1770739816900649196L;

        for (String sceneId : sceneIdList) {
            Map<String, Object> params = new HashMap<>();
            params.put("sceneId", sceneId);
            params.put("id1", id++);
            params.put("id2", id++);

            String sql = new StringSubstitutor(params).replace(sqlTem);
            System.out.println(sql);
        }
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    static class SceneKeyName {
        private long sceneId;
        private String uniqueKey;
        private String sceneName;
    }
}
